package com.hackintosh.hybird;

/**
 * @description：
 * @author：twislyn
 * @date：Created in 2021/06/06
 * @modified By：
 * @version: 1.0
 */
public class PrototypeMemento {
    public static void main(String[] args) {
        OriginatorPrototype originatorPrototype = new OriginatorPrototype("Q1");
        System.out.println("初始状态：" + originatorPrototype.getState());

        PrototypeCaretaker caretaker = new PrototypeCaretaker();
        caretaker.setOpt(originatorPrototype.createMemento());

        originatorPrototype.setState("Q2");
        System.out.println("新的状态：" + originatorPrototype.getState());

        originatorPrototype.restoreMemento(caretaker.getOpt());
        System.out.println("恢复状态：" + originatorPrototype.getState());
    }
}
